//
//  IAVoiceLoadingView.m
//  VoiceClass
//
//  Created by caoxiaobo on 2018/1/1.
//  Copyright © 2018年 YRX. All rights reserved.
//

#import "IAVoiceLoadingView.h"
#import "UIImage+GIF.h"
#import "Definition.h"
#import "UIView+Extension.h"

@interface IAVoiceLoadingView ()

@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UIImageView *animateImageView;

@end

@implementation IAVoiceLoadingView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        _animateImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        _animateImageView.contentMode = UIViewContentModeScaleAspectFit;
        _animateImageView.image = [UIImage sd_animatedGIFNamed:@"search_voice_record"];
        [self addSubview:_animateImageView];
        
        _statusLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _statusLabel.font = [UIFont systemFontOfSize:15];
        _statusLabel.textAlignment = NSTextAlignmentCenter;
        _statusLabel.text = @"正在语音听写...";
        [self addSubview:_statusLabel];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    CGFloat w = 200.0f;
    CGFloat h = 50.0f;
    CGFloat x = (self.cWidth - w) * 0.5;
    CGFloat y = (self.cHeight - h) * 0.5;
    self.animateImageView.frame = CGRectMake(x, y, w, h);
    
    self.statusLabel.cWidth = self.cWidth;
    self.statusLabel.cHeight = 40.0f;
    self.statusLabel.cX = 0.0f;
    self.statusLabel.cY = CGRectGetMaxY(self.animateImageView.frame) + 10.0f;
}

@end
